﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
using System.Diagnostics;

namespace Car
{
	/// <summary>
	/// Interaction logic for App.xaml
	/// </summary>
	public partial class App : Application
	{
		public App()
		{
			//this.DispatcherUnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException);
			this.Exit += new ExitEventHandler(App_Exit);
			if (Environment.GetCommandLineArgs().Length > 1)
			{
				try
				{
					System.Threading.Thread.Sleep(Int32.Parse(Environment.GetCommandLineArgs()[1]));
					Process.Start("C:\\Program Files\\Teamspeak2_RC2\\TeamSpeak.exe",
						"192.168.1.10:8767?nickname=Starlight?password=egegunesekibi");
				}
				catch 
				{
					MessageBox.Show(Environment.GetCommandLineArgs()[1]);
				}
			}
		}

		void App_Exit(object sender, ExitEventArgs e)
		{
			Process.GetCurrentProcess().Kill();
		}

		void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
		{
			//e.Handled = true;
			MessageBox.Show(String.Format("{0}\n{1}\n{2}\n{3}",
				e.Exception.InnerException.Message,
				e.Exception.InnerException.Data,
				e.Exception.InnerException.Source,
				e.Exception.InnerException.StackTrace));
			Process.GetCurrentProcess().Kill();
		}
	}
}
